<?php

use think\facade\Route;

/** 版块/模式 */
Route::group('/module', function () {
    Route::get('list',      'getModuleList')->middleware(['withoutLogin']);    // 版块列表

})->prefix('\app\exam\service\Module@');

/** 通用 */
Route::group('topic', function () {
    Route::get('$',            'getTopicInfo');        // 试题信息
    Route::get('wrong/list',   'getWrongTopicList');   // 错题本 - 获取错误试题列表
    Route::get('wrong',        'getWrongTopic');       // 错题本 - 获取单个错误试题信息
    Route::post('wrong',       'postTopicAnswer');     // 错题本 - 答案提交
    Route::group('collect', function () {
        Route::get('list',     'getCollectList');      // 收藏试题列表
        Route::post('$',       'collectTopic');        // 收藏试题
    });
})->prefix('\app\exam\service\Common@');

/** 知识点练习 */
Route::group('/point', function () {

    Route::get('list',      'getPointList')->middleware(['withoutLogin']);     // 知识点列表
    Route::get('category',  'getCategoryList')->middleware(['withoutLogin']);     // 知识点分类列表

    Route::group('prictice', function () {
        Route::get('basic',     'getPracticeBase');     // 知识点练习列表
        Route::get('topic',     'getPointTopic');       // 知识点练习试题信息
        Route::post('topic',    'postTopicAnswer');     // 知识点练习答案提交
    });

})->prefix('\app\exam\service\Point@');

/** 专项练习 */
Route::group('special', function () {
    Route::get('list',                  'getSpecialList');      // 专项列表
    Route::get('search',                'search');              // 专项列表搜索
})->prefix('\app\exam\service\Special@')->middleware(['withoutLogin']);

Route::group('special', function () {
    Route::get('base',              'getSpecialBase');      // 获取指定专项的试题基础信息
    Route::get('topic',             'getSpecialTopic');     // 专项练习试题信息
    Route::post('topic',            'postSpecialAnswer');   // 专项练习答案提交
    Route::delete('record',         'clearSpecialRecord');  // 清空专项记录
})->prefix('\app\exam\service\Special@');

/** 公开考试 */
Route::group('/paper', function () {
    Route::group(function(){
        Route::get('list',      'getExaminationList');      // 公开考试列表
        Route::get('search',    'search');                  // 公开考试搜索
        Route::get('category',  'getExaminationCategory');  // 公开考试分类
        Route::get('catetree',  'getExaminationCatetree');  // 公开考试分类树
    })->prefix('\app\exam\service\Examination@')->middleware(['withoutLogin']);

    Route::group(function(){
        Route::get('base',          'getPaperBase');        // 获取指定考试的基础信息
        Route::get('topic',         'getPaperTopic');       // 公开考试试题信息
        Route::post('answer',       'postPaperAnswer');     // 公开考试答案提交
        Route::get('<type>',        'getPapers');           // 获取待/已阅试卷列表
        Route::get('users',         'getPaperUsers');       // 获取试卷用户列表
        Route::get('user/fetch',    'getPaperUserFetch');   // 获取阅卷渲染数据
        Route::post('user',         'postPaperUserScore');  // 提交阅卷数据
    })->prefix('\app\exam\service\Paper@')->pattern(['type' => 'uncorrected|corrected']);

});

/** 套卷练习 */
Route::group('/rollup', function () {
    Route::get('list',      'getRollupList');       // 套卷列表
    Route::get('search',    'search');              // 套卷搜索
    Route::get('detail',    'getRollupDetail');     // 套卷详情
    // Route::get('catetree',  'getPaperCatetree');    // 套卷分类树
})->prefix('\app\exam\service\Rollup@')->middleware(['withoutLogin']);

Route::group('/rollup/paper', function () {
    Route::get('base',      'getRollupPaperBase');    // 获取指定套卷试卷的基础信息
    Route::get('topic',     'getRollupPaperTopic');   // 套卷试题信息
    Route::post('answer',   'postRollupPaperAnswer'); // 套卷答案提交

})->prefix('\app\exam\service\Rollup@');